package com.lws.systembarsample

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.core.view.*
import org.w3c.dom.Text

class FullScreenPaddingActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_full_screen_inset)

        ViewCompat.getWindowInsetsController(window.decorView)?.isAppearanceLightStatusBars = true
        ViewCompat.getWindowInsetsController(window.decorView)?.isAppearanceLightNavigationBars= true


        //设置decorView全屏显示,即显示区域延伸至状态栏、导航栏
        WindowCompat.setDecorFitsSystemWindows(window, false)


        val topTextView:TextView =findViewById(R.id.topTextView)
        ViewCompat.setOnApplyWindowInsetsListener(topTextView){ view: View, windowInsetsCompat: WindowInsetsCompat ->

            //给这个View通过设置 Margin 或者 padding ,使该View不被状态栏遮挡
            //这里以修改padding为例
            view.updatePadding(top = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.statusBars()).top)

            //返回原来的Inset，以便它们继续向下传递
            windowInsetsCompat
        }



        val bottomTextView:TextView =findViewById(R.id.bottomTextView)
        ViewCompat.setOnApplyWindowInsetsListener(bottomTextView){ view: View, windowInsetsCompat: WindowInsetsCompat ->

            //给这个View通过设置 Margin 或者 padding ,使该View不被导航栏遮挡
            //这里以修改padding为例
            view.updatePadding(bottom = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom)

            //返回原来的Inset，以便它们继续向下传递
            windowInsetsCompat
        }
    }
}